package com.mingqi.enetconnected.primary.mytask.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Toast;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.mingqi.enetconnected.R;
import com.mingqi.enetconnected.base.BaseActivity;
import com.mingqi.enetconnected.primary.mytask.adapter.NotificationMessageAdapter;
import com.mingqi.enetconnected.util.resource.ResourceUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;

public class NotificationMessageActivity extends BaseActivity {

    @BindView(R.id.rv_message)
    RecyclerView mRvMessage;

    private int[] notificationImgs = {R.drawable.ic_task_notification,R.drawable.ic_alarm_remind
            ,R.drawable.ic_loot_notification,R.drawable.ic_system_message, R.drawable.ic_other_notification};

    private int[] notificationTitles = {R.string.task_notification,R.string.alarm_remind
            ,R.string.loot_notification,R.string.system_message, R.string.other_notification};

    @Override
    protected int getLayoutID() {
        return R.layout.activity_notification_message;
    }

    @Override
    protected void initView() {

        setTitleName(ResourceUtils.getString(R.string.message));

        mTVTitle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                showProDialogHint();
            }
        });
    }

    @Override
    protected void initData() {

        mRvMessage.setLayoutManager(new LinearLayoutManager(mContext));

        final List<Map<String,Integer>> messageList = new ArrayList<>();
        for (int i = 0; i < 5; i++) {

            Map<String,Integer> map = new HashMap<>();
            map.put("img",notificationImgs[i]);
            map.put("title",notificationTitles[i]);

            messageList.add(map);
        }

        NotificationMessageAdapter adapter = new NotificationMessageAdapter(messageList);
        mRvMessage.setAdapter(adapter);
        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

                Toast.makeText(mContext, "" + ResourceUtils.getString(messageList.get(position).get("title")), Toast.LENGTH_SHORT).show();

                Bundle bundle = new Bundle();
                bundle.putString("title",ResourceUtils.getString(messageList.get(position).get("title")));
                startActivity(MessageDetailsActivity.class,bundle);
            }
        });
    }
}
